home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / qlib205.zip / QLIB.ZIP / TEST / STATS.ASM < prev    next >
Assembly Source File  |  1997-05-28  |  4KB  |  130 lines

  1. ; This program will dump data (usually stuff just in the header) of ANY file
  2. ; that I've created.
  3.  
  4. ; NOTE : this program requires PLAYv1.0 and M32vx.x installed
  5. ;        see Qlib Download Add-ons section on my homepage
  6.  
  7. ; to do : PIC, PAcKs? ...
  8.  
  9. include qlib.inc
  10. include string.inc
  11. include stdio.inc
  12. include dos.inc
  13. include process.inc
  14.  
  15. .data
  16.   hand dw ?
  17.   header db 3 dup (?)
  18.  
  19. .code
  20. main proc,argc:byte,argv:dword
  21.   callp print,"File STATS v1.02  by : Peter Quiring\n"
  22.   .if argc!=2
  23.     callp print,"Usage : STATS (file)        [Supports EXE]\n"
  24.     ret
  25.   .else
  26.     callp print,"\n"
  27.   .endif
  28.   mov eax,argv
  29.   mov eax,[eax+1*4]  ;1st argument (file name)
  30.   callp open,eax,0
  31.   .if eax==ERROR
  32.     callp print,"File not found\n"
  33.     callp exit,0
  34.   .endif
  35.   mov hand,ax
  36.   callp read,hand,offset header,3
  37.   callp lseek,hand,0,SEEK_SET
  38. ;  callp memcmp,offset header,"FLK",3
  39. ;  .if !eax
  40. ;    jmp FLK
  41. ;  .endif
  42. ;  callp memcmp,offset header,"M32",3
  43. ;  .if !eax
  44. ;    jmp M32
  45. ;  .endif
  46.   callp memcmp,offset header,"MZ",2
  47.   .if !eax
  48.     jmp EXE
  49.   .endif
  50.   callp close,hand
  51.   callp printf,"File type unknown\n"
  52.   ret
  53. done::
  54.   callp close,hand
  55.   ret
  56. main endp
  57.  
  58.  
  59. comment ^
  60. .data
  61.   flk_head play_flk <>
  62.  
  63. .code
  64. FLK:
  65.   callp read,hand,offset flk_head,sizeof flk_head
  66.   callp printf," FLK format :\n"
  67.   callp printf,"X : %w\n",flk_head.xres
  68.   callp printf,"Y : %w\n",flk_head.yres
  69.   callp printf,"bpp : %b\n",flk_head.bpp
  70.   callp printf,"Frames : %w\n",flk_head.total
  71.   callp printf,"Speed : %d\n",flk_head.spd
  72.   callp printf,"Flgs : %b\n",flk_head.flgs
  73.   jmp done
  74.  
  75. .data
  76.   m32_head m32_headers <>
  77.  
  78. .code
  79. M32:
  80.   callp read,hand,offset m32_head,sizeof m32_head
  81.   mov al,[m32_head.head+4]
  82.   callp printf," M32 format : Ver%c\n",al
  83.   callp printf,"Songname    : %s\n",offset m32_head.songname
  84.   callp printf,"# patterns  : %b\n",m32_head.npat
  85.   callp printf,"# channels  : %b\n",m32_head.nch
  86.   callp printf,"bits/sample : %b\n",m32_head.res
  87.   callp printf,"SampleRate  : %w\n",m32_head.freq
  88.   callp printf,"Speed       : %b\n",m32_head.spd
  89.   callp printf,"Notes/sec   : %b",m32_head.nfreq
  90.   .if m32_head.nfreq==64
  91.     callp printf,"  (M32 format)\n"
  92.   .else  ;50!
  93.     callp printf,"  (Amiga format)\n"
  94.   .endif
  95.   callp printf,"Samples     : "
  96.   .if m32_head.saminc
  97.     callp print,"YES\n"
  98.   .else
  99.     callp print,"No\n"
  100.   .endif
  101.   jmp done
  102. ^
  103.  
  104. .data
  105.   exe_hdr db 28 dup (?)
  106. .code
  107. EXE:
  108.   callp print,"EXE format:\n\n"
  109.   callp read,hand,offset exe_hdr,sizeof exe_hdr
  110.   callp printf,"Offset    Value           Description\n------------------------------\n"
  111.   callp printf,"  0h(0)   %04Xh(%05d)    Signature (MZ)\n",wptr exe_hdr[0],wptr exe_hdr[0]
  112.   callp printf,"  2h(2)   %04Xh(%05d)    Extra Bytes\n",wptr exe_hdr[2],wptr exe_hdr[2]
  113.   callp printf,"  4h(4)   %04Xh(%05d)    Pages(512 bytes)\n",wptr exe_hdr[4],wptr exe_hdr[4]
  114.   callp printf,"  6h(6)   %04Xh(%05d)    # Reloc Items\n",wptr exe_hdr[6],wptr exe_hdr[6]
  115.   callp printf,"  8h(8)   %04Xh(%05d)    EXE Header size(*16)\n",wptr exe_hdr[8],wptr exe_hdr[8]
  116.   callp printf," 0ah(10)  %04Xh(%05d)    Min alloc(*16)\n",wptr exe_hdr[0ah],wptr exe_hdr[0ah]
  117.   callp printf," 0ch(12)  %04Xh(%05d)    Max alloc(*16)\n",wptr exe_hdr[0ch],wptr exe_hdr[0ch]
  118.   callp printf," 0eh(14)  %04Xh(%05d)    Init SS\n",wptr exe_hdr[0eh],wptr exe_hdr[0eh]
  119.   callp printf," 10h(16)  %04Xh(%05d)    Init SP\n",wptr exe_hdr[10h],wptr exe_hdr[10h]
  120.   callp printf," 12h(18)  %04Xh(%05d)    Check Sum\n",wptr exe_hdr[12h],wptr exe_hdr[12h]
  121.   callp printf," 14h(20)  %04Xh(%05d)    Init IP\n",wptr exe_hdr[14h],wptr exe_hdr[14h]
  122.   callp printf," 16h(22)  %04Xh(%05d)    Init CS\n",wptr exe_hdr[16h],wptr exe_hdr[16h]
  123.   callp printf," 18h(24)  %04Xh(%05d)    Reloc Table Offset\n",wptr exe_hdr[18h],wptr exe_hdr[18h]
  124.   callp printf," 1ah(26)  %04Xh(%05d)    Overlay #\n",wptr exe_hdr[1ah],wptr exe_hdr[1ah]
  125.   jmp done
  126.  
  127. end
  128.  
  129.  
  130.